/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ccedeno
 * SELECT t FROM Trabajador t join t.usuario u  WHERE u.idUsuario = :codtra   ok  Join
 *      "SELECT d FROM DocAdjunto d WHERE d.fk_cod_exp = :fxcodexp"),
  */
@Entity
@Table(name = "doc_adjunto", catalog = "emilima_tradoc", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DocAdjunto.findAll", query = "SELECT d FROM DocAdjunto d"),
    @NamedQuery(name = "DocAdjunto.findByIdDocAdj", query = "SELECT d FROM DocAdjunto d WHERE d.idDocAdj = :idDocAdj"),
    @NamedQuery(name = "DocAdjunto.findIdExpedien", query = "SELECT d FROM DocAdjunto d WHERE d.expediente.codExp = :CodExp"),
    @NamedQuery(name = "DocAdjunto.findByObservacion", query = "SELECT d FROM DocAdjunto d WHERE d.observacion = :observacion"),
    @NamedQuery(name = "DocAdjunto.findByFechIngre", query = "SELECT d FROM DocAdjunto d WHERE d.fechIngre = :fechIngre")})
public class DocAdjunto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_doc_adj", nullable = false)
    private Integer idDocAdj;
    @Size(max = 255)
    @Column(name = "observacion", length = 255)
    private String observacion;
    @Column(name = "fech_ingre")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechIngre;
    @JoinColumn(name = "fk_estado_doc", referencedColumnName = "id_estado_doc", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private EstadoDoc estadoDoc;
    @JoinColumn(name = "fk_estado", referencedColumnName = "id_estado", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Estado estado;
    @JoinColumn(name = "fk_cod_exp", referencedColumnName = "cod_exp", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Expediente expediente;

    public DocAdjunto() {
    }

    public DocAdjunto(Integer idDocAdj) {
        this.idDocAdj = idDocAdj;
    }

    public Integer getIdDocAdj() {
        return idDocAdj;
    }

    public void setIdDocAdj(Integer idDocAdj) {
        this.idDocAdj = idDocAdj;
    }

    public String getObservacion() {
        return observacion;
    }

    public void setObservacion(String observacion) {
        this.observacion = observacion;
    }

    public Date getFechIngre() {
        return fechIngre;
    }

    public void setFechIngre(Date fechIngre) {
        this.fechIngre = fechIngre;
    }

    public EstadoDoc getEstadoDoc() {
        return estadoDoc;
    }

    public void setEstadoDoc(EstadoDoc estadoDoc) {
        this.estadoDoc = estadoDoc;
    }

    public Estado getEstado() {
        return estado;
    }

    public void setEstado(Estado estado) {
        this.estado = estado;
    }

    public Expediente getExpediente() {
        return expediente;
    }

    public void setExpediente(Expediente expediente) {
        this.expediente = expediente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDocAdj != null ? idDocAdj.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DocAdjunto)) {
            return false;
        }
        DocAdjunto other = (DocAdjunto) object;
        if ((this.idDocAdj == null && other.idDocAdj != null) || (this.idDocAdj != null && !this.idDocAdj.equals(other.idDocAdj))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.DocAdjunto[ idDocAdj=" + idDocAdj + " ]";
    }
}
